/*
 * Copyright (c) 2006-2021, RT-Thread Development Team
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Change Logs:
 * Date           Author       Notes
 * 2023-10-07     huger       the first version
 */
#ifndef APPLICATIONS_APP_APP_IO_H_
#define APPLICATIONS_APP_BSP_IO_H_

#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */

#include "bsp/bsp.h"
#include "mod/mod_filter.h"


typedef enum {
    e_pow_pc,
    e_pow_driver,
    e_pow_actuator,
    e_pow_updown,
    e_pow_rotale,
    e_pow_rcm,
} pow_index;

typedef enum {
    e_key_start,
    e_key_drag,
} key_index;

typedef enum {
    e_sensor_actuator_4_dn = 0,
    e_sensor_actuator_4_up,
    e_sensor_actuator_3_dn,
    e_sensor_actuator_3_up,
    e_sensor_actuator_2_dn,
    e_sensor_actuator_2_up,
    e_sensor_actuator_1_dn,
    e_sensor_actuator_1_up,
    e_sensor_vh_dn,
    e_sensor_vh_up,
    e_sensor_ro_r,
    e_sensor_ro_l,
    e_sensor_ho_top,
    e_sensor_ho_botton
} sensor_index;

typedef struct {
    uint8_t key_st[2];          //0 开始按键 1 拖动
    uint8_t sensor_st[14];
    uint8_t pow_st[8];
    uint8_t emg_st[2];             //急停

    uint8_t sd_st;              //音频short down

    uint8_t brake_st;           //刹车
    uint8_t beep_st;
    uint8_t beep_freq;

    struct{
        uint8_t style;
        uint8_t freq;
        uint8_t style_backup;
        uint8_t freq_backup;
    }rgb;
} iomap;

extern void app_io_get_gpio_map(iomap* map);
extern void app_io_set_gpio_map(iomap* map);
extern void app_io_init(void);
extern void app_brake_state_set(uint8_t state);

#ifdef __cplusplus
}
#endif /* __cplusplus */

#endif /* APPLICATIONS_APP_APP_IO_H_ */
